﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WinUI {
    public class CodeGenerationUtil {
        public static string GenJavaName(string dbName) {
            // e.g: is_competitor --> IsCompetitor

            string[] strs = dbName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);

            string name = "";
            foreach (string str in strs) {
                string newStr = str.Substring(0, 1).ToUpper() + str.Substring(1);
                name += newStr;
            }

            return name;
        }

        public static string GenJavaNameLowerCase(string dbName) {
            // e.g: is_competitor --> IsCompetitor

            string[] strs = dbName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);

            string name = "";
            for (int i = 0; i < strs.Length; i++) {
                string str = strs[i];
                string newStr;
                if (i == 0) {
                    newStr = str.Substring(0, 1).ToLower() + str.Substring(1);
                } else {
                    newStr = str.Substring(0, 1).ToUpper() + str.Substring(1);
                }
                name += newStr;
            }

            return name;
        }

        public static string GenDisplayName(string dbName) {
            // e.g: is_competitor --> IsCompetitor

            string[] strs = dbName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);

            string name = "";
            foreach (string str in strs) {
                if (name != string.Empty) {
                    name += " ";
                }

                string newStr = str.Substring(0, 1).ToUpper() + str.Substring(1);
                name += newStr;
            }

            return name;
        }
    }
}
